import { Component, OnDestroy } from '@angular/core';
import { Subscription } from 'rxjs/Subscription';
import { RegPageProvider } from './reg.page.provider';

@Component({
    selector: 'reg-page',
    templateUrl: './reg.page.html',
    styleUrls: ['./reg.page.css'],
    providers: [RegPageProvider]
})

export class RegPage {

    user: any = {
        username: '',
        password: ''
    };
    constructor(private service: RegPageProvider) { }

    reg(){
        if(this.user.username !='' && this.user.password !=''){
            this.getHttp(this.user);
        }
    }

    ngOnDestroy() {
        if (this.ajaxSub) {
            this.ajaxSub.unsubscribe();
        }
    }

    ajaxSub: Subscription;
    getHttp(param) { 
        this.ajaxSub = this.service.reg(param).subscribe((res:any)=>{

        });
    }
}